
import { edgeRequest, mockRequest } from '@/utils/request';
import { APEDGE_PREFIX } from '@/utils/const';
export const listAPI = '/node';
export const groupListAPI = '/nodeGroup';
export const serviceListAPI = '/serviceNode';

export async function getList (data: object) {
  return await edgeRequest(`/node`, {
    method: 'GET',
    params: data,
  })
}

export async function delEdgeNode (id: string | number) {
  return await edgeRequest(`/node/${id}`, {
    method: 'DELETE',
  });
}

export async function getDetail (id: string | number) {
  return await edgeRequest(`/node/${id}`, {
    method: 'GET',
  });
}

export async function addEdgeNode (params: object) {
  return await edgeRequest(`/node`, {
    method: 'POST',
    data: params,
  })
}

export async function addEdgeNodeGroup (params: object) {
  return await edgeRequest(`/nodeGroup`, {
    method: 'POST',
    data: params,
  })
}

export async function getGroupDetail (id: string | number) {
  return await edgeRequest(`/nodeGroup/${id}`, {
    method: 'GET',
  });
}

export async function getTypes () {
  return await edgeRequest(`/node/nodeType`, {
    method: 'GET',
  })
}

export async function getScripts (data: object) {
  return await edgeRequest(`/node/scripts`, {
    method: 'GET',
    params: data,
  })
}

export const getCode = async () => await edgeRequest('/node/offline', { method: 'GET' });

export const getDownload = `${APEDGE_PREFIX}/node/download`;
